﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="材料到发货管理.aspx.cs" Inherits="syc.Store.材料到发货管理" %>
<html>
<head>
<title></title>
<link href="/TreeView/TreeView.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" language="javascript" src="/TreeView/TreeView.js"></script>
<style>
div.AutoComplete_Container{position:absolute; z-index:2;border:solid 1px #dd3333;background-color:#ffffff;padding:1px;font-size:14px;color:#ff0000;}
#AutoComplete_CurrentLine{ background-color:#0000cc;}
tr.AutoComplete_Row{font-size:14px;color:#6f320a;height:18px;cursor:pointer;}
tr.AutoComplete_HotRow{font-size:14px;color:#6f320a; background-color:#ffee88;height:18px;cursor:pointer;}
</style>
</head>
<body>
<script type="text/javascript" language="javascript" src="/common.js"></script>
<form id="form1" runat="server">
<asp:Label ID="SqlText" runat="server" Text="" Visible="false"></asp:Label>
<asp:Label ID="Label_FID" runat="server" Text="" Visible="false"></asp:Label>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
onselected="SqlDataSource1_Selected" 
DeleteCommand="delete from 材料到发货 where ID=@ID and 单据ID=0"
>
<DeleteParameters>
<asp:Parameter Name="ID" DbType="Int32" Size="4"/>
</DeleteParameters>
</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" 
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" 
SelectCommand="select 0 as ID,'全部' as 名称 union all select ID, 名称 FROM 材料供货单位"></asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource3" runat="server" 
SelectCommand="select ID, cast(id as varchar)+' '+名称 as 名称 FROM 单位编码 where ID Between 350000 and 359999;"
ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>" >

</asp:SqlDataSource>

<div id="wintop" class="wintop">到发货管理</div>

<asp:Panel ID="Panel1" runat="server" CssClass="panel">
    <input type="button" value="到 货" class="button" onclick="parent.swin2_load('/Store/材料到货记录录入.aspx',600,340);"/>
    
    <asp:Button ID="Button_Out" runat="server" Text="发 货" CssClass="button"  
        UseSubmitBehavior="False"/>
    
    <asp:Button ID="Button_Edit" runat="server" Text="查看/修改" CssClass="button"  
        UseSubmitBehavior="False" Enabled="false"/>
        
    <asp:Button ID="Button_Bill" runat="server" Text="填写入库单" CssClass="button"  
        UseSubmitBehavior="False" Enabled="false" />
        
    <asp:Button ID="Button_Delete" runat="server" Text="删 除" CssClass="button"  
        UseSubmitBehavior="False" 
        onclick="Button_Delete_Click"
        OnClientClick="if(!confirm('确认要删除该条记录吗？'))return(false);" />
    
</asp:Panel>

<asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="到发货记录查询">
供货单位：<asp:DropDownList 
    ID="GongHuo" runat="server" DataSourceID="SqlDataSource2"  Width="160px"
    DataTextField="名称" DataValueField="ID"></asp:DropDownList>

<span style="margin-left:8px;"></span>使用单位：<asp:DropDownList 
    ID="FenChang" runat="server" DataSourceID="SqlDataSource3"  Width="160px"
    DataTextField="名称" DataValueField="ID"></asp:DropDownList>

<span style="margin-left:8px;"></span>物料品名：<asp:TextBox ID="PinMing" runat="server" CssClass="textbox" Width="105px"></asp:TextBox>
<span style="margin-left:8px;"></span>物料编码：<asp:TextBox ID="BianMa" runat="server" CssClass="textbox" Width="90px"></asp:TextBox>

<div style="font-size:6px;height:6px;line-height:6px;"></div>
显示筛选：<asp:DropDownList ID="XianShi" runat="server" Width="160px">
<asp:ListItem Value="0">全部显示记录</asp:ListItem>
<asp:ListItem Value="1">仅显示到货记录</asp:ListItem>
<asp:ListItem Value="2">仅显示发货记录</asp:ListItem>
<asp:ListItem Value="3">仅显示未入库到货记录</asp:ListItem>
<asp:ListItem Value="4">仅显示未出库发货记录</asp:ListItem>
</asp:DropDownList>
<span style="margin-left:8px;"></span>起始日期：<asp:TextBox ID="Date1" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));" />
<span style="margin-left:8px;"></span>截止日期：<asp:TextBox ID="Date2" runat="server" CssClass="textbox" Width="105px"></asp:TextBox><img alt="" src="/Icons/29.png" align="middle" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));" />

<span style="margin-left:5px;"></span><asp:Button ID="Button_Query" runat="server" Text="查 询" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Query_Click" />

<asp:Button ID="Button_Stat" runat="server" Text="分类统计" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Stat_Click"  />
        
<asp:Button ID="Button_Reset" runat="server" Text="清空条件" UseSubmitBehavior="false" 
        CssClass="mbutton" onclick="Button_Reset_Click" />
    <asp:Label ID="Label_Result" runat="server" Text="" ForeColor="Red"></asp:Label>
</asp:Panel>


<div class="gridframe">
    <div class="gridview">
    
        <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
            <tr>
	            <td class="grid-title" colspan="2"><div style="float:left;margin-top:3px;">到发货记录</div><div style="float:right;">
                    <asp:DropDownList ID="PageSizeOption" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="PageSizeOption_SelectedIndexChanged">
                    <asp:ListItem Value="10">10 项/页</asp:ListItem>
                    <asp:ListItem Value="20" Selected="True">20 项/页</asp:ListItem>
                    <asp:ListItem Value="30">30 项/页</asp:ListItem>
                    <asp:ListItem Value="50">50 项/页</asp:ListItem>
                    <asp:ListItem Value="100">100 项/页</asp:ListItem>
                    </asp:DropDownList></div></td>
	        </tr>
	        <tr>
                <td class="grid-back" width=200 align=left  valign="top">
	                <div style="height:26px;text-align:center;padding-top:4px;font-size:14px;color:#6f320a;">物料分类目录</div>
	                <div id="MyTree" style=" background-color:#ffffff; overflow:scroll;"></div>
	            </td>
	            <td class="grid-back">
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CssClass="grid" DataKeyNames="ID,到发,单据ID" 
                        DataSourceID="SqlDataSource1"
                        PageSize="20"
                        GridLines="None" ondatabound="GridView1_DataBound" 
                        onpageindexchanged="GridView1_PageIndexChanged" AllowSorting="True" 
                        UseAccessibleHeader="False" 
                        onselectedindexchanged="GridView1_SelectedIndexChanged" 
                        onrowdatabound="GridView1_RowDataBound">
                        <PagerSettings Visible="False" />
                        <RowStyle CssClass="grid-row-normal" />
                        <Columns>
                            <asp:TemplateField HeaderText="">
                                <ItemTemplate>
                                    <asp:Button ID="Button_xz" runat="server" CommandName="Select" Text="选择" CssClass="hide"/>
                                    <asp:Image ID="Image_icon" runat="server" ImageUrl="/Icons/online.gif" />
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="到发">
                                <ItemTemplate>
                                    <img src='/Images/io-<%# Eval("到发") %>.png' />
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="30px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="物料编码" SortExpression="材料ID">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bm" runat="server" Text='<%# Eval("材料ID","{0:D10}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="品名" SortExpression="材料ID">
                                <ItemTemplate>
                                    <asp:Label ID="Label_pm" runat="server" Text='<%# Eval("品名") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="规格">
                                <ItemTemplate>
                                    <asp:Label ID="Label_gg" runat="server" Text='<%# Eval("规格") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="单位">
                                <ItemTemplate>
                                    <asp:Label ID="Label_dw" runat="server" Text='<%# Eval("单位") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="数量">
                                <ItemTemplate>
                                    <asp:Label ID="Label_sl" runat="server" Text='<%# Eval("数量") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="单价">
                                <ItemTemplate>
                                    <asp:Label ID="Label_dj" runat="server" Text='<%# Eval("单价") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>
                          
                            <asp:TemplateField HeaderText="金额">
                                <ItemTemplate>
                                    <asp:Label ID="Label_je" runat="server" Text='<%# Eval("金额") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Right" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="日期" SortExpression="日期">
                                <ItemTemplate>
                                    <asp:Label ID="Label8" runat="server" Text='<%# Eval("日期","{0:d}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="供货或使用">
                                <ItemTemplate>
                                    <asp:Label ID="Label_gy" runat="server" Text='<%# Eval("供货或使用") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" Width="100px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="保管员">
                                <ItemTemplate>
                                    <asp:Label ID="Label_bgy" runat="server" Text='<%# Eval("保管员") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="60px" />
                            </asp:TemplateField>

                            <asp:TemplateField HeaderText="单据号">
                                <ItemTemplate>
                                    <asp:Label ID="Label_djh" runat="server" Text='<%# Eval("单据号","{0:D7}") %>'></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                            
                            <asp:TemplateField HeaderText="选取填单" Visible="false">
                                <ItemTemplate>
                                    <asp:CheckBox ID="CheckBox1" runat="server" 
                                        oncheckedchanged="CheckBox1_CheckedChanged" AutoPostBack="true" />
                                    <asp:Label ID="Label_rowid" runat="server" Text='<%# Eval("ID") %>' Visible="false"></asp:Label>
                                </ItemTemplate>
                                <HeaderStyle CssClass="grid-header" />
                                <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="50px" />
                            </asp:TemplateField>
                      
                        </Columns>
                        <SelectedRowStyle CssClass="grid-row-selected" />
                      </asp:GridView>
	            </td>
            </tr>
            <tr>
	            <td colspan="2">   
	                <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>

	            </td>
            </tr>
        </table>
        

    </div>
</div>

</form>
<script>
    var notice = '<%=this.Notice %>';
    if (notice != '') {
        parent.showmsgbox(notice);
    }
</script>
<script>
    var textboxs = document.getElementsByTagName("input");
    var i;
    for (i = 0; i < textboxs.length; i++) {
        if (textboxs[i].className == "textbox") {
            //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
            textboxs[i].onfocus = function(e) { this.select(); };
        }
        else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
            textboxs[i].onfocus = function(e) { this.select(); };
        }
    }
    var rows = document.getElementsByTagName("tr");
    for (i = 0; i < rows.length; i++) {

        if (rows[i].className == "grid-row-normal") {
            rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
            rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
            rows[i].onclick = selectRow;
        }
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName == "INPUT" && tag.className == "textbox" || tag.tagName == "SELECT") {
            if (e.keyCode == 13) e.keyCode = 9;
        }
    }

    TreeView_Href = "/Store/物料分类查询.ashx?s=";
    TreeView_Action = "/Store/材料到发货管理.aspx?fid=";
    TreeView_Create("MyTree", "0000000", "物料中心", "/TreeView/home.png");
    var fid = "<%=this.Label_FID.Text %>";
    var ca = document.getElementById(fid).firstChild.lastChild;
    ca.className = "cnode";

    function qr() { return !confirm('确认要删除该条记录吗？'); }



    var BianMa = document.getElementById("BianMa");

    //自动完成
    var AutoComplete_Container = document.getElementById("AutoComplete_Container");
    if (!AutoComplete_Container) {//创建容器
        AutoComplete_Container = document.createElement("DIV");
        AutoComplete_Container.id = "AutoComplete_Container";
        AutoComplete_Container.className = "AutoComplete_Container";
        AutoComplete_Container.style.display = "none";
        document.body.appendChild(AutoComplete_Container);
    }
    var AutoComplete_Lists = new Array();
    var AutoComplete_Target = null;
    var AutoComplete_LastValue = "";
    function AutoComplete_SetHotRow(o) {
        var hotrow = document.getElementById("AutoComplete_HotRow");
        hotrow.id = "";
        hotrow.className = "AutoComplete_Row";
        o.id = "AutoComplete_HotRow";
        o.className = "AutoComplete_HotRow";
    }
    function AutoComplete_Select() {
        var hotrow = document.getElementById("AutoComplete_HotRow");
        if (hotrow) {
            var li = AutoComplete_Lists[hotrow.rowIndex].split("\t");
            BianMa.value = li[0];
            AutoComplete_Target.value = li[1];
        }
    }
    function AutoComplete_Response(http) {
        if (http.status != 200) {
            alert("服务器错误: " + http.status + " " + http.statusText);
            return;
        }
        if (http.responseText == "") {
            AutoComplete_Container.innerHTML = "<div style=padding:3px;font-size:14px;>没有查询到您录入的品种</div>";
        }
        else {
            var className = "AutoComplete_HotRow";
            var rs = http.responseText.split("\n");
            var tmp = "<table>";
            var cs;
            var id = " id=AutoComplete_HotRow";
            for (var i = 0; i < rs.length - 1; i++) {
                AutoComplete_Lists[i] = rs[i];
                cs = rs[i].split("\t");
                tmp += "<tr" + id + " class=" + className + " onmousemove=AutoComplete_SetHotRow(this); onmousedown=AutoComplete_Select();><td style='width:90px;padding:1px 2px 0px 2px;'>"
                    + cs[0] + "</td><td align=center style=width:120px>"
                    + cs[1] + "</td><td align=center style=width:120px>"
                    + cs[2] + "</td><td align=center style=width:80px>"
                    + cs[4] + "/" + cs[3] + "</td></tr>";
                className = "AutoComplete_Row";
                id = "";
            }
            tmp += "</table>";
            AutoComplete_Container.innerHTML = tmp;
        }

        AutoComplete_Container.style.display = "";
        AutoComplete_Container.style.top = (getObjectTop(AutoComplete_Target) + AutoComplete_Target.clientHeight + 2) + "px";
        AutoComplete_Container.style.left = (getObjectLeft(AutoComplete_Target)) + "px";
    };
    function AutoComplete_HideContainer() {
        if (AutoComplete_Target == null) {
            AutoComplete_Container.style.display = "none";
        }
    }
    function AutoComplete_SetValue(value) {
        if (typeof (AutoComplete_Target.value) != "undefined") AutoComplete_Target.value = value;
        else if (typeof (AutoComplete_Target.innerText) != "undefined") AutoComplete_Target.innerText = value;
        else if (typeof (AutoComplete_Target.textContent) != "undefined") AutoComplete_Target.textContent = value;
    }
    function AutoComplete() {
        if (AutoComplete_Target == null) {
            AutoComplete_Container.style.display = "none";
        }
        else if (AutoComplete_Target != document.activeElement) {
            AutoComplete_Target = null;
            setTimeout("AutoComplete_HideContainer()", 100);
        }
        else {
            var txt;
            if (typeof (AutoComplete_Target.value) != "undefined") txt = AutoComplete_Target.value;
            else if (typeof (AutoComplete_Target.innerText) != "undefined") txt = AutoComplete_Target.innerText;
            else if (typeof (AutoComplete_Target.textContent) != "undefined") txt = AutoComplete_Target.textContent;

            txt = txt.replace(/^\s+/, '').replace(/\s+$/, '');
            if (txt == "") {
                AutoComplete_Container.style.display = "none";
            }
            else if (txt != AutoComplete_LastValue) {
                AutoComplete_LastValue = txt;
                var request = createRequest(AutoComplete_Response);
                request.open("GET", encodeURI("/Store/物料品种查询.ashx?s=" + txt), true);
                request.send(null);
            }
        }
        setTimeout("AutoComplete()", 200);
    }

    document.onkeydown = function(e) {
        if (!e) e = window.event;
        var tag = e.srcElement;
        if (!tag) tag = e.target;
        if (tag.tagName != "INPUT" || tag.className != "textbox") return;
        if (tag.id == "BeiZhu") return;

        if (tag == AutoComplete_Target && AutoComplete_Container.style.display != "none") {
            if (e.keyCode != 9) {
                BianMa.value = "";
            }
            if (e.keyCode == 38) {
                var hotrow = document.getElementById("AutoComplete_HotRow");
                if (hotrow) {
                    var lt = hotrow.parentNode.parentNode;
                    hotrow.id = "";
                    hotrow.className = "AutoComplete_Row";
                    if (hotrow.rowIndex > 0) {
                        lt.rows[hotrow.rowIndex - 1].id = "AutoComplete_HotRow";
                        lt.rows[hotrow.rowIndex - 1].className = "AutoComplete_HotRow";
                    }
                    else {
                        lt.rows[lt.rows.length - 1].id = "AutoComplete_HotRow";
                        lt.rows[lt.rows.length - 1].className = "AutoComplete_HotRow";
                    }
                }
            }
            else if (e.keyCode == 40) {
                var hotrow = document.getElementById("AutoComplete_HotRow");
                if (hotrow) {
                    var lt = hotrow.parentNode.parentNode;
                    hotrow.id = "";
                    hotrow.className = "AutoComplete_Row";
                    if (hotrow.rowIndex < lt.rows.length - 1) {
                        lt.rows[hotrow.rowIndex + 1].id = "AutoComplete_HotRow";
                        lt.rows[hotrow.rowIndex + 1].className = "AutoComplete_HotRow";
                    }
                    else {
                        lt.rows[0].id = "AutoComplete_HotRow";
                        lt.rows[0].className = "AutoComplete_HotRow";
                    }
                }
            }
            else if (e.keyCode == 13) {
                AutoComplete_Select();
                e.keyCode = 9;
            }
            else if (e.keyCode == 27) {
                AutoComplete_LastValue = "";
                tag.value = "";
            }
        }
        else if (e.keyCode == 13) {
            e.keyCode = 9;
        }

    }
    setTimeout("AutoComplete()", 200);
    //自动完成结束
    document.getElementById("PinMing").onfocus = function() {
        AutoComplete_LastValue = "";
        AutoComplete_Target = this;
        this.select();
    }
    
</script>
</body>
</html>
